<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>上海泛软科技有限公司-后台登陆</title>
<meta name="robots" content="nofollow" />
<meta name=”viewport” content=”width=device-width, initial-scale=1, maximum-scale=1″>
<link href="/Public/Css/admin-style.css" rel="stylesheet" type="text/css" />
<link href="/Public/Css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="/Public/Css/bootstrap.min.css" rel="stylesheet" type="text/css" />


<script language="javascript" type="text/javascript" src="/Public/Js/jquery.js"></script>
<script language="javascript" type="text/javascript" src="/Public/Js/admin-common.js"></script>
<script language="javascript" type="text/javascript" src="/Public/Js/bootstrap.min.js"></script>
<!--<script language="javascript" type="text/javascript" src="/Public/Js/bootstrap.js"></script> -->
<script language="javascript" type="text/javascript" src="/Public/Js/rock_customer_list.js"></script>
<script language="javascript" type="text/javascript" src="/Public/Js/demo.js"></script>
<script language="javascript" type="text/javascript" src="/Public/Js/blob.js"></script>
<script language="javascript" type="text/javascript" src="/Public/Js/FileSaver.min.js"></script>
<script language="javascript" type="text/javascript" src="/Public/Js/jquery.base64.js"></script>
<script language="javascript" type="text/javascript" src="/Public/Js/jquery-1.10.2.min.js"></script>
<script language="javascript" type="text/javascript" src="/Public/Js/tableExport.js"></script>
<script language="javascript" type="text/javascript" src="/Public/Js/xlsx.core.min.js"></script>
</head>

<body>


</style>
 <h4>数据统计增加</h4>
  <form class="form-horizontal" role="form" style="width:100%;" enctype="multipart/form-data" name="form1" method="post" action="<?php echo U('data_Statistics_Add_Ok');?>">
   <div style="width:80%; border: 1px solid #ccc;padding:10px;margin-bottom:30px;margin-left:10%"> 
	<div style="width:60%;margin-left:15%">  	 
	 <h4>数据信息:</h4>
	 <div class="form-group">
		<label for="firstname" class="col-sm-2 control-label">测试时间</label>
		<div class="col-sm-10">
		  <input required="required" type="text" class="form-control" name="test_time" id="test_time" placeholder="请输入测试时间">
		</div>
	  </div>
	  <div class="form-group">
		<label for="lastname" class="col-sm-2 control-label">温度</label>
		<div class="col-sm-10">
		  <input required="required" type="text" name="temperature" class="form-control" id="temperature" placeholder="请输入度数">
		</div>
	  </div>
	  <div class="form-group">
		<label for="firstname" class="col-sm-2 control-label">备注</label>
		<div class="col-sm-10">
		   <input required="required" type="text" name="remark" class="form-control" id="remark" placeholder="请输入备注">
		
		</div>
	  </div>
	  <div class="form-group user_old1" >
		<label for="" class="col-sm-2 control-label">选择医院:</label>
		<div class="col-sm-10">
		  <select  style="width:100%" name="data_hospital" id="data_hospital">
			<option>请选择</option>
			<?php if(is_array($all_hos)): $i = 0; $__LIST__ = $all_hos;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$all_hos): $mod = ($i % 2 );++$i;?><option dd="<?php echo ($all_hos['h_id']); ?>"><?php echo ($all_hos["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
		  </select>	
		  <!-- <input required="required" type="text" name="h_hid" class="form-control" id="h_hid" placeholder="请输入备注">
		 -->
		</div>
	  </div>
	  
	   <div class="form-group user_old" >
		<label for="" class="col-sm-2 control-label">选择病人:</label>
		<div class="col-sm-10">
		  <select  style="width:100%" name="data_patient" id="data_patient" class="sele">
			
		  </select>	
		   <input style="display:none" required="required" type="text" name="p_pid" class="form-control" id="p_pid" placeholder="请输入备注">
		
		</div>  
	  </div>
	  <div class="form-group user_old" >
		<label for="" class="col-sm-2 control-label">选择用户:</label>
		<div class="col-sm-10">
		  <select  style="width:100%" name="data_user" id="data_user" class="sele">
			
		  </select>	
		  <input style="display:none" required="required" type="text" name="u_uid" class="form-control" id="u_uid" placeholder="请输入备注">
		
		</div>
	  </div>
	   <div class="form-group user_old"  >
		<label for="" class="col-sm-2 control-label">选择设备:</label>
		<div class="col-sm-10">
		  <select  style="width:100%" name="data_device" id="data_device" class="sele">
			
		  </select>	
		  <input style="display:none" required="required" type="text" name="d_did" class="form-control" id="d_did" placeholder="请输入备注">
		
		</div>
	  </div>
	 </div>
    </div>	
	
	
	
	
    <div style="width:80%; border: 1px solid #ccc;padding:10px;margin-bottom:30px;margin-left:10%;display:none"> 
	<div style="width:60%;margin-left:15%">  	 
	 <h4>医院信息:</h4>
	 <div class="form-group old_hos">
		<label for="" class="col-sm-2 control-label">医院</label>
		<div class="col-sm-10">
		  <select style="width:100%" name="hospital_name" id="hospital_name" onchange="choose_hos()">
			<?php if(is_array($hospital_name)): $i = 0; $__LIST__ = $hospital_name;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$hospital_name): $mod = ($i % 2 );++$i;?><option h_id="<?php echo ($hospital_name['h_id']); ?>"><?php echo ($hospital_name["h_name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
		  </select>	
		</div>
	  </div>
	   <input style="display:none" type="text" class="form-control" name="hosid" id="hosid" placeholder="">
		 
	  <a id="add_new_hos" onclick="add_new_hos()">增加新的医院</a>
	  <div class="form-group new_add">
		<label for="" class="col-sm-2 control-label">医院名称:</label>
		<div class="col-sm-10">
		  <input  type="text" class="form-control" name="hos_name" id="hos_name" placeholder="请输入医院名称">
		</div>
	  </div>
	  
	  <div class="form-group new_add">
		<label for="" class="col-sm-2 control-label">省份:</label>
		<div class="col-sm-10">
		  <input  type="text" class="form-control" name="province" id="province" placeholder="请输入城市">
		</div>
	  </div>
	  <div class="form-group new_add">
		<label for="" class="col-sm-2 control-label">城市、区、县</label>
		<div class="col-sm-10">
		  <input  type="text" class="form-control" name="city" id="city" placeholder="请输入区、县">
		</div>
	  </div>
	  <div class="form-group new_add">
		<label for="" class="col-sm-2 control-label">经纬度</label>
		<div class="col-sm-10">
		  <input  style="width:40%;float:left;margin-right:5%" type="text" class="form-control" name="lng" id="lng" placeholder="请输入经度">
		  <input  style="width:40%;float:left;margin-right:2%" type="text" class="form-control" name="lat" id="lat" placeholder="请输入纬度">
		  <button type="button" class="btn btn-primary btn-sm" onclick="obtain()">获取</button>
		 
		</div>
	  </div>
	 </div>
    </div>	
 
    <div style="width:80%; border: 1px solid #ccc;padding:10px;margin-bottom:30px;margin-left:10%;display:none"> 
	<div style="width:60%;margin-left:15%">  	 
	 <h4>用户信息:</h4>
	  <div class="form-group user_old" >
		<label for="" class="col-sm-2 control-label">手机号:</label>
		<div class="col-sm-10">
		  <select  style="width:100%" name="user_tel" id="user_tel" onchange="choose_user()">
			<option></option>
		  </select>	
		</div>
	  </div>
	   <div class="form-group user_old">
		<label for="" class="col-sm-2 control-label">姓名:</label>
		<div class="col-sm-10">
		  <input readonly="readonly" type="text" class="form-control" name="user_name" id="user_name" placeholder="请输入用户姓名">
		</div>
	  </div>
	   <input  type="text" style="display:none" class="form-control" name="user_id" id="user_id" placeholder="">
	  <a id="add_new_user" onclick="add_new_user()">增加新的用户</a>
	    <div class="form-group user_new">
		 <label for="" class="col-sm-2 control-label">姓名:</label>
		 <div class="col-sm-10">
		  <input  type="text" class="form-control" name="new_user_name" id="new_user_name" placeholder="请输入用户姓名">
		</div>
	   </div>
	   <div class="form-group user_new">
		 <label for="" class="col-sm-2 control-label">密码:</label>
		 <div class="col-sm-10">
		  <input  type="password" class="form-control" name="new_user_password" id="new_user_password" placeholder="请输入用密码">
		</div>
	   </div>
	    <div class="form-group user_new">
		 <label for="" class="col-sm-2 control-label">手机号:</label>
		 <div class="col-sm-10">
		  <input  type="text" class="form-control" name="new_user_Tel" id="new_user_Tel" placeholder="请输入手机号">
		</div>
	   </div>
	   <div class="form-group user_new">
		 <label for="" class="col-sm-2 control-label">职位:</label>
		 <div class="col-sm-10">
		  <input  type="text" class="form-control" name="new_user_postion" id="new_user_postion" placeholder="请输入职位">
		</div>
	   </div>
	   <div class="form-group user_new">
		 <label for="" class="col-sm-2 control-label">工作区域:</label>
		 <div class="col-sm-10">
		  <input  type="text" class="form-control" name="new_user_work" id="new_user_work" placeholder="请输入工作区域">
		</div>
	   </div>
	 </div>
    </div>	
     
	<div class="form-group" style="text-align:right;margin-right:10%">
       <div class="col-sm-offset-2 col-sm-10">
         <button type="submit" class="btn btn-info sub_data">提交</button>
       </div>
    </div>

 </form>
 <script>
  var myTime = getNowFormatDate();
  $("#test_time").val(myTime);
  var oPatient = document.getElementById("data_patient");
  var oUser = document.getElementById("data_user");
  var oDevice = document.getElementById("data_device");
  var h_data = document.getElementById("data_hospital");
  $(".sele").attr("disabled","disabled");
  if(h_data.value == "请选择"){
    $(".sub_data").attr("disabled","disabled");
  }else{
    $(".sub_data").attr("disabled",false);
  }
  oPatient.onchange = function(){//拿到patient id
    var index = this.selectedIndex; 
    var p_id =  this.options[index].getAttribute("pid"); 
	$("#p_pid").val(p_id);
  }
   oUser.onchange = function(){//拿到user id
    var index = this.selectedIndex; 
    var u_id =  this.options[index].getAttribute("uid"); 
	$("#u_uid").val(u_id);
  }
  oDevice.onchange = function(){//拿到device id
    var index = this.selectedIndex; 
    var d_id =  this.options[index].getAttribute("did"); 
	$("#d_did").val(d_id);
  }
   //选择医院
   h_data.onchange = function(){
     var index = this.selectedIndex; 
     var h_id =  this.options[index].getAttribute("dd"); 
     var value = this.options[index].value; 
	 //$("#h_hid").val(h_id);
	if(value == "请选择"){
	  $(".sele").attr("disabled",true);
	}else{
	  $(".sele").attr("disabled",false);
	   $.ajax({
  	    url: '/javajy/index.php/Admin/Wenlian/data_Statistics_Add_obtin',
  	    type: 'POST',
 	    dataType: 'JSON',//here
		data:{
		  h_id:h_id
		 },
 	     success: function(data){
		   var html = '';
		   var html1 ='';
		   var html2 = '';
		   var wu = 0;
		   for(var d = 0; d <data.length; d++){
		      for(var i = 0; i <data[0].length; i++){
		        if(data[0][i]["u_id"] == "无"){
				  wu++;
				}
		      }
			  for(var j = 0; j < data[1].length; j++){
		        if(data[1][j]["p_id"] == "无"){
				  wu++;
				}
		      }
			 for(var k = 0; k < data[2].length; k++){
		        if(data[2][k]["d_id"]== "无"){
				  wu++;
				}
		      }
		   }
		   if(wu > 0){
		     $(".sub_data").attr("disabled","disabled");
		   }else{
		     $(".sub_data").attr("disabled",false);
		   }
		   for(var i = 0; i <data[0].length; i++){
		     $("#u_uid").val(data[0][0]["u_id"]);//
		     html+=
		     '<option uid = '+data[0][i]["u_id"]+'>'+data[0][i]["u_realname"]+'</option>'
		   }
		   oUser.innerHTML = html;
		   
		   for(var j = 0; j < data[1].length; j++){
		      $("#p_pid").val(data[1][0]["p_id"]);//
		      html1+=
			 '<option pid = '+data[1][j]["p_id"]+'>'+data[1][j]["p_name"]+'[编号:'+data[1][j]["p_num"]+']</option>'
		   }
		   oPatient.innerHTML = html1;
		   for(var k = 0; k < data[2].length; k++){
		      $("#d_did").val(data[2][0]["d_id"]);//
		      html2+=
			 '<option did = '+data[2][k]["d_id"]+'>'+data[2][k]["d_number"]+'</option>'
		   }
		   oDevice.innerHTML = html2;
		 }
	  });
	}
 }   
  function getNowFormatDate() {
    var date = new Date();
    var seperator1 = "-";
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
	var hours = date.getHours(); //获取当前小时数(0-23)
    var min =  date.getMinutes(); //获取当前分钟数(0-59)
    var second = date.getSeconds(); //获取当前秒数(0-59)
	
    if (month >= 1 && month <= 9) {
         month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
	if(hours >=0 && hours <= 9){
	   hours = "0" + hours;
	}
	if(min >=0 && min <= 9){
	   min = "0" + min;
	}
	if(second >=0 && second <= 9){
	   second = "0" + second;
	}
    var currentdate = year + seperator1 + month + seperator1 + strDate +" "+hours +":" + min+":" + second;
    return currentdate;
  }
 </script>

</body>
</html>